package com.wzdigit.wms.basic.mapper.core.order;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wzdigit.framework.orm.mybatis.MyBatisRepository;
import com.wzdigit.wms.basic.domain.asn.AsnDtl;
import com.wzdigit.wms.basic.domain.asn.dto.AsnSaleInDto;
import com.wzdigit.wms.basic.domain.dtos.trsn.TrsnFpDto;
import com.wzdigit.wms.basic.client.request.asn.ReceiveReportSelectRequest;
import com.wzdigit.wms.basic.client.response.asnHeader.ReceiveReportZhuExt;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 收货通知单明细 Mapper 接口
 * </p>
 *
 * @author
 * @since 2021-01-12
 */
@MyBatisRepository
public interface AsnDtlMapper extends BaseMapper<AsnDtl> {


    /**
     * 根据asnNo查所有明细
     *
     * @param asnNo
     * @return
     */
    List<AsnDtl> selectByAsnNo(@Param("asnNo") String asnNo);

    /**
     * 增加送货数量/收货数量
     *
     * @param id
     * @param qty
     * @param status
     */
    void plusRecQtyAndOrderQtyById(@Param("id") Integer id,
                                   @Param("qty") BigDecimal qty,
                                   @Param("status") Integer status,
                                   @Param("userName") String userName);

    /**
     * 获取收获报表主档信息
     *
     * @param search
     * @return
     */
    List<ReceiveReportZhuExt> searchReceiveReport(@Param("search") ReceiveReportSelectRequest search,
                                                  @Param("asnTypeList") List<String> asnTypeList);

    List<ReceiveReportZhuExt> searchReceiveReportNew(@Param("search") ReceiveReportSelectRequest search,
                                                  @Param("asnTypeList") List<String> asnTypeList);


    List<TrsnFpDto> findTrsnFpDtoList(@Param("asnNo") String asnNo, @Param("asnLineNo") String asnLineNo, @Param("drawCode") String drawCode, @Param("goodsSnList") List<String> goodsSnList);

    
    int updateStatusBySsnNoAndAsnTypeAndStatus(
    		@Param("status") Integer status, @Param("asnNo") String asnNo, 
    		@Param("asnType") String asnType, @Param("byStatus") Integer byStatus);
    
    List<TrsnFpDto> findTrsnFpDtoListInStorage(@Param("asnNo") String asnNo, @Param("asnLineNo") String asnLineNo, @Param("drawCode") String drawCode, @Param("goodsSnList") List<String> goodsSnList, @Param("invUpdateFlag") int invUpdateFlag);

    void updateLotNoAndAttr(AsnDtl asnDtl);

    List<AsnSaleInDto> selectInSale(@Param("prdReceiveCode") String prdReceiveCode, @Param("udf1") String udf1);

    Integer selectMaxLineId(@Param("asnHeaderId") Integer asnHeaderId);
}
